package com.dyz.LeetCodeforSwordFingerOffer;

import java.util.HashSet;

/**
 * @ClassNamefindRepeatNumber03
 * @Description
 * @Author: daiyizheng
 * @Date2021/6/13 3:53 下午
 * @Version V1.0
 **/
public class findRepeatNumber03 {
    public int findRepeatNumber(int[] nums) {
        if (nums==null|| nums.length==0){return -1;}
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0; i<nums.length;i++){
            if(!set.add(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }
}
